import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:xiongan_app_yy/common/user_singleton.dart';
import 'package:xiongan_app_yy/net/internet.dart';
import 'package:xiongan_app_yy/utils/toast_utils.dart';

class MessageProvider extends ChangeNotifier {
  bool _netStatus1 = false;
  List _listData = List();
  int num = 0; //列表数据
  get netStatus1 => _netStatus1;

  get listData => _listData;

  void getList({Map<String, dynamic> sendObj}) async {
    Map<String, dynamic> sendObj = {
      "pageNo": -1,
      "creatorUserId":DataSingleton().Data.id,
      "workuserid":DataSingleton().Data.id,
    };
    _netStatus1 = true;
    _listData = [];
    notifyListeners();
    Map<String, dynamic> res = await Internet().get(
        "OMS/MiApprovalResultNotify/GetAllApprovalResultNotifyList",
        params: sendObj);
    if (res['flag'] == "success") {
      _listData = res['datas'];
      num = _listData.length;
    }else{
      TostUtil.showToast(res['msg']);
    }
    _netStatus1 = false;
    notifyListeners();
  }

  Future<dynamic> sendMessageInfo(String id) async {
    Map<String, dynamic> sendObj = {
      "warehouseid": DataSingleton().warehouseChoice.id,
      "id": id
    };
    Map<String, dynamic> res = await Internet().post(
      "OMS//MiApprovalResultNotify/UpdateMiApprovalResultNotify",
      params: sendObj,
      options: new Options(
          contentType: ContentType.parse("application/x-www-form-urlencoded")),
    );
    return res['datas'];
  }
}
